/*
 * Copyright (c) 2005 -2008 Reliable Source, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Mozilla Public License v.1.1,
 * BSD, and Eclipse Public License v1.0 which accompanies this
 * distribution and is available at:
 *
 * 		http://www.eclipse.org/legal/epl-v10.html
 * 		http://www.opensource.org/licenses/bsd-license.php
 * 		http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * Contributors:
 *     IBM Corporation	     -  http://ibm.com
 *     	- initial API and implementation
 *
 *     patientos.org         - http://patientos.org
 *     	- domain and database persistence layer
 *
 *     Reliable Source, Inc. - http://reliablesource.org
 *     	- Symbiosys Application Framework,
 *     	- Symbiosys Application, Symbiosys Product
 *
 */
package org.reliablesource.client.ui.symbiosys.platform.views;

import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.properties.IPropertySheetPage;
import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
import org.reliablesource.client.ui.viewers.IReliableViewer;
import org.reliablesource.client.ui.workbench.views.ReliableViewPart;
import org.reliablesource.symbiosys.platform.viewers.PatientListViewer;


public class PatientChartViewPart extends ReliableViewPart implements ITabbedPropertySheetPageContributor {
    public static final String ID = "org.reliablesource.client.ui.symbiosys.platform.view.patientchart"; //$NON-NLS-1$

    private TabbedPropertySheetPage tabbedPropertySheetPage;
    
    /*
     * (non-Javadoc)
     * @see org.reliablesource.client.ui.workbench.views.ReliableViewPart#createPartControl(org.eclipse.swt.widgets.Composite)
     */
    public void createPartControl(Composite _parent) {
        super.createPartControl(_parent);
        
        getSite().setSelectionProvider(viewer.getChildren()[0]);
    }
    
    @Override
    protected IReliableViewer createViewer() {
        return new PatientListViewer();
    }

    @Override
    public void dispose() {
        viewer.dispose();
        super.dispose();
    }

    /* (non-Javadoc)
     * @see org.reliablesource.client.ui.workbench.views.IReliableViewPart#getPartId()
     */
    public String getPartId() {
        return ID;
    }

    /* (non-Javadoc)
     * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor#getContributorId()
     */
    @Override
    public String getContributorId() {
	return getSite().getId();
    }
    
    /**
     * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
     */
    public Object getAdapter(Class adapter) {
        if (adapter == IPropertySheetPage.class) {
            if (tabbedPropertySheetPage == null) {
                tabbedPropertySheetPage = new TabbedPropertySheetPage(this);
            }
            return tabbedPropertySheetPage;
        }
        return super.getAdapter(adapter);
    }


    public TabbedPropertySheetPage getTabbedPropertySheetPage() {
        return tabbedPropertySheetPage;
    }
}
